#######################

PROGRAM = fcc
BUILD_DIR = ../../build
BUILD_FILE = $(BUILD_DIR)/$(PROGRAM).exe
TMP_DIR = ../../tmp/cygwin
SRC_DIR = ../../src

OBJS = main.o parser.o lexer.o utils.o
SRCS = $(shell find $(SRC_DIR) -name *.cpp *.c)

LEX = flex
YACC = bison
CC = gcc

#######################
default:
		@echo make clean = cleans project
		@echo make build = build project
		@echo make test  = tests project

$(BUILD_FILE): $(OBJS)
		$(CC) -o $(BUILD_FILE) $(OBJS)

.c.o:
		@echo compiling $<
		$(CC) -c $<

lexer.c: lexer.l utils.h parser.h
		@echo building lexer
		$(LEX) -o lexer.c lexer.l

parser.c: parser.y utils.h
		@echo building parser
		$(YACC) -d -o parser.c parser.y

#######################

build: $(BUILD_FILE)

clean:
		@rm -f $(BUILD_FILE) *.o
		@rm -f parser.c parser.h lexer.c
		@echo DONE

test: $(BUILD_FILE)
		$(BUILD_FILE) $(BUILD_DIR)/test.c

bau:
		echo $(SRCS)